﻿@using SmartSiteManagementSystem.Models.ProjectManage;
@using SmartSiteManagementSystem.IServices;
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.BodyClass = "easyui-layout";
    DayProjectInfo dayProjectInfo = ViewBag.dayProjectInfo;
}
    <div class="easyui-panel" style="padding:5px;">    
        <input id="DayProjectId" type="hidden" value="@dayProjectInfo.DayProjectId" />
        <table class="gou-formTable" style="align-content:center;">
            <tbody>              
                <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">*子计划名称:</td>
                    <td align="left" class="">
                         <input id="DayProjectName" name="DayProjectName" type="text" value="@dayProjectInfo.DayProjectName" />    
                    </td>
                </tr>
                 <tr>
                    <td align="right" class="gou-formTable-title" style="width:160px;">任务类型:</td>
                    <td align="left" class="">
                  <select id="combo_DayProjectType" name="combo_DayProjectType" class="easyui-combobox" style="width:150px;">
                  <option value="-1">请选择任务类型 </option>
                  @foreach (var item in ViewBag.dayProjectTypeInfoList as IList<DayProjectTypeInfo>)
                {

                    <option value="@item.DayProjectTypeId"> @(item.DayProjectTypeName) </option>
                }
                  </select>
                    </td>
                </tr>
                 <tr> 
                    <td align="right" class="gou-formTable-title" style="width:160px;">*计划时间:</td>
                    <td align="left" class="">
                  
                <input id="StartTime" name="StartTime" class="easyui-datetimebox" value="@dayProjectInfo.StartTimeStr">
                <input id="EndTime" name="EndTime" class="easyui-datetimebox" value="@dayProjectInfo.EndTimeStr">  
                    </td>
                </tr>  

                 






                <tr>
                    <td colspan="2" align="center">                       
                            <a href="javascript:void(0)" id="hfSave" class="easyui-linkbutton" iconcls="icon-save" onclick="Save();" style="width:150px;height:32px">保存</a>                                           
                    </td>
                </tr>
            </tbody>
        </table>

    </div>



    <script type="text/javascript">        


    $(document).ready(function(){
        @if(dayProjectInfo.DayProjectId>0){
        <text>
             $('#combo_DayProjectType').combobox('setValue',@(dayProjectInfo.DayProjectType) );
       /* $('#StartTime').combobox('setValue',@(dayProjectInfo.StartTime) );
        $('#EndTime').combobox('setValue',@(dayProjectInfo.EndTime) );*/
        </text>
          }
     });





        //保存
        function Save() {

            //验证必选项******************************************************************
            var DayProjectName = $("#DayProjectName").val();
            if (DayProjectName == "") {
                $.messager.alert('提示', '计划名称必填项!');
                return false;
            }
           /*var Descript = $("#Descript").val();*/

                        //商品分类
                var DayProjectType = $("[name=combo_DayProjectType]").val();
                if (DayProjectType == 0) {
                    $.messager.alert('提示信息', "请选择任务类别", 'info').panel('move', {
                        top: 100
                    });
                    return;
                }

            var DayProjectId = $("#DayProjectId").val();
            var StartTime = $("input[name=StartTime]").val();
            var EndTime = $("input[name=EndTime]").val();
           if (StartTime == "" || EndTime=="" ) {
                $.messager.alert('提示', '请选择计划开始结束时间!');
                return false;
            }
            
            var param = {ProjectId: @(ViewBag.projectId), DayProjectId: DayProjectId, DayProjectName: DayProjectName,DayProjectType:DayProjectType,StartTime: StartTime,EndTime: EndTime};
            $.ajax({
                "type": "Post",
                "url": "ajaxAddOrEditDayProject?t=" + new Date().getTime(),
                "dataType": "json",
                "data": param,
                "success": function (data) {
                    if (data.Code == 1) {
                        window.location.href = "DayProjectIndex?projectId=@(ViewBag.projectId)";
                    }
                    else
                    {
                        $.messager.alert('提示', data.Msg);
                    }
                }
            });
        }
</script>    
